package thread1009;

public class RunnableDemo implements Runnable {
    private static int tickts=10;

    @Override
    public void run() {
      while (true){
          if (tickts>0){
              System.out.println(Thread.currentThread().getName()+"买票"+tickts);
              tickts--;

          }else {
              System.out.println("票卖光了"+Thread.currentThread().getName());
              break;
          }
      }
    }

    public static void main(String[] args) {
        Runnable demo = new RunnableDemo();
        Thread thread = new Thread(demo);
        Thread thread1 = new Thread(demo);
        Thread thread2 = new Thread(demo);
        thread.start();
        thread1.start();
        thread2.start();

    }
}
